home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / setProject.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.6 KB  |  133 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Jan. 1997
  22. //  Author:         DSW
  23. //
  24. //  Description:
  25. //      setProject is used to set the current project.
  26. //
  27. //  Input Arguments:
  28. //        A string. If empty, the project browser comes up for the
  29. //        new project. Otherwise the project is set to the given
  30. //        string.
  31. // 
  32. //  Return Value:
  33. //        None
  34. //
  35. //<doc>
  36. //<name setProject>
  37. //<owner "Alias|Wavefront Unsupported">
  38. //
  39. //<synopsis>
  40. //        setproject $newProject
  41. //
  42. //<returns>
  43. //        none
  44. //
  45. //<description>
  46. //      Sets the current project.  If no string is specified, the
  47. //        Project Browser window will open.
  48. //
  49. //
  50. //<examples>
  51. //    setProject "C:/Documents and Settings/kilroy/My Documents/maya/projects/default";
  52. //
  53. //</doc>
  54.  
  55. global proc int sp_setLocalWorkspaceCallback (string $path, string $type)
  56. //
  57. //    Description:
  58. //        Open the selected workspace and make it the new local workspace.
  59. //
  60. {
  61.     int $result;
  62.     string $workspace = `workspace -q -fn`;
  63.  
  64.     string $typeList[] = `file -q -typ $path`;
  65.     if (size($typeList) > 0 && $typeList[0] == "directory") {
  66.         workspace -o $path;
  67.  
  68.         // If the browser is up then we must reset it.
  69.         //
  70.  
  71.         if (`window -ex projectViewerWindow`) {
  72.             pv_resetWorkspace;    // Force the layout to be redone.
  73.         }
  74.  
  75.         np_resetBrowserPrefs;
  76.  
  77.         $result = true;
  78.     } else {
  79.         confirmDialog -m ($path+" is not a directory.") 
  80.             -b "OK" -db "OK" -parent projectViewerWindow;
  81.         $result = false;
  82.     }
  83.  
  84.     // They picked a new one:
  85.     if ( true == $result && $path != $workspace )
  86.     {
  87.         addRecentProject( $path );
  88.         // We also want to update the edit box if they're editing the 'current'
  89.         // (the new one should now be the 'current')
  90.         if ( `window -ex newProjectWindow` ) 
  91.         {
  92.             string $title = `window -q -t newProjectWindow`;
  93.             // If the use is editing the project, then we want to 
  94.             // refresh the Edit window ("2" is edit mode for projectSetup)
  95.             // If they were setting up a new one we close the newProjectWindow
  96.             if ( $title == "Edit Project" )
  97.                 projectSetup( 2 );
  98.             else
  99.                 deleteUI newProjectWindow;
  100.             // We remove the window if they were setting a new one
  101.         }
  102.     }
  103.  
  104.  
  105.     return $result;
  106. }
  107.  
  108. global proc setProject ( string $newProject )
  109. //
  110. //    Description:
  111. //        Set the current workspace to the one selected by the user.
  112. //
  113. {    
  114.     // No name given - browse for it
  115.     if ( size( $newProject ) == 0 )
  116.     {
  117.         // Set the directory to the users project area.
  118.         //
  119.         string $wsDir = dirname( `workspace -q -fn` );
  120.  
  121.         if (`file -q -ex $wsDir`) {
  122.             workspace -dir $wsDir;
  123.         }
  124.  
  125.         fileBrowser "sp_setLocalWorkspaceCallback" "Set Project" "" 4;        
  126.     }
  127.     // Try to set it directly from the name given
  128.     else
  129.     {
  130.         sp_setLocalWorkspaceCallback $newProject "directory";
  131.     }
  132. }
  133.